home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / util / pack / xpk25dev.lha / include / libraries / xpk.i < prev    next >
Text File  |  1992-08-09  |  12KB  |  312 lines

  1.     IFND    LIBRARIES_XPK_I
  2. LIBRARIES_XPK_I    SET    1
  3.  
  4. **
  5. **    $Filename: libraries/xpk.i $
  6. **    $Release: 0.9 $
  7. **
  8. **
  9. **
  10. **    (C) Copyright 1991 Christian Schneider & U. Dominik Mueller
  11. **        All Rights Reserved
  12. **
  13.  
  14.     IFND    EXEC_LIBRARIES_I
  15.     include "exec/libraries.i"
  16.     ENDC
  17.  
  18.     IFND    UTILITY_TAGITEM_I
  19. * Extracted (without permission) from utility/tagitem.h for you poor saps
  20. *   who don't have the 2.0 headers... :-)
  21.  STRUCTURE    TagItem,0
  22.     ULONG    ti_Tag        ; identifies the type of this item
  23.     ULONG    ti_Data        ; type-specific data, can be a pointer
  24.     LABEL    ti_SIZEOF
  25. TAG_DONE    EQU    0  ; terminates array of TagItems. ti_Data unused
  26. TAG_USER    EQU    $80000000  ; differentiates user tags from system tags
  27.     ENDC
  28.  
  29.     IFND UTILITY_HOOKS_I
  30.  STRUCTURE HOOK,MLN_SIZE
  31.     APTR    h_Entry            ; assembler entry point
  32.     APTR    h_SubEntry        ; optional HLL entry point
  33.     APTR    h_Data            ; owner specific
  34.  LABEL        h_SIZEOF
  35.     ENDC
  36.  
  37. XPKNAME        MACRO
  38.       DC.B  'xpkmaster.library',0
  39.       ENDM
  40.  
  41. ******************************************************************************
  42. *
  43. *      The packing/unpacking tags
  44. *
  45. *
  46.  
  47. XPK_TagBase    equ    (TAG_USER+'XP')
  48.  
  49. * Caller must supply ONE of these to tell Xpk#?ackFile where to get data from *
  50. XPK_InName    equ    (XPK_TagBase+$01)    ; Name of a single data file */
  51. XPK_InFH    equ    (XPK_TagBase+$02)    ; File handle - read from current position */
  52. XPK_InBuf    equ    (XPK_TagBase+$03)    ; Unblocked buffer - must also supply InLen */
  53. XPK_InHook    equ    (XPK_TagBase+$04)    ; Callback Hook to get input data */
  54.  
  55. * Caller must supply ONE of these to tell Xpk#?ackFile where to send data to *
  56. XPK_OutName    equ    (XPK_TagBase+$10)    ; Write (or overwrite) this data file */
  57. XPK_OutFH    equ    (XPK_TagBase+$11)    ; File handle - write from current position on */
  58. XPK_OutBuf    equ    (XPK_TagBase+$12)    ; Unblocked buffer - must also supply OutBufLen */
  59. XPK_GetOutBuf    equ    (XPK_TagBase+$13)    ; Master allocates OutBuf - ti_Data points to buffer pointer */
  60. XPK_OutHook    equ    (XPK_TagBase+$14)    ; Callback Hook to get output buffers */
  61.  
  62. * Other junk *
  63. XPK_InLen    equ    (XPK_TagBase+$20)    ; len of data in input buffer */
  64. XPK_OutBufLen    equ    (XPK_TagBase+$21)    ; len of output buffer */
  65. XPK_GetOutLen    equ    (XPK_TagBase+$22)    ; ti_Data points to long to receive OutLen */
  66. XPK_GetOutBufLen equ    (XPK_TagBase+$23)    ; ti_Data points to long to receive OutBufLen */
  67. XPK_Password    equ    (XPK_TagBase+$24)    ; password for de/encoding */
  68. XPK_GetError    equ    (XPK_TagBase+$25)    ; ti_Data points to buffer for error message */
  69. XPK_OutMemType    equ    (XPK_TagBase+$26)    ; Memory type for output buffer */
  70. XPK_PassThru    equ    (XPK_TagBase+$27)    ; Bool: Pass through unrecognized formats */
  71. XPK_StepDown    equ    (XPK_TagBase+$28)    ; Bool: Step down pack method if necessary */
  72. XPK_ChunkHook    equ    (XPK_TagBase+$29)    ; Call this Hook between chunks */
  73. XPK_PackMethod    equ    (XPK_TagBase+$2a)    ; Do a FindMethod before packing */
  74. XPK_ChunkSize    equ    (XPK_TagBase+$2b)    ; Chunk size to try to pack with */
  75. XPK_PackMode    equ    (XPK_TagBase+$2c)    ; Packing mode for sublib to use */
  76. XPK_NoClobber    equ    (XPK_TagBase+$2d)    ; Don't overwrite existing files  */
  77. XPK_Ignore    equ    (XPK_TagBase+$2e)    ; Skip this tag                   */
  78. XPK_TaskPri    equ    (XPK_TagBase+$2f)    ; Change priority for (un)packing */
  79. XPK_FileName    equ    (XPK_TagBase+$30)    ; File name in progress report
  80. XPK_ShortError    equ    (XPK_TagBase+$31)    ; Output short error messages     */
  81. XPK_PackersQuery equ    (XPK_TagBase+$32)    ; Query available packers         */
  82. XPK_PackerQuery    equ    (XPK_TagBase+$33)    ; Query properties of a packer    */
  83. XPK_ModeQuery    equ    (XPK_TagBase+$34)    ; Query properties of packmode    */
  84. XPK_LossyOK    equ    (XPK_TagBase+$35)    ; Lossy packing permitted? def.=no*/
  85.  
  86. XPK_FindMethod    equ    XPK_PackMethod
  87.  
  88. XPK_MARGIN    equ    256
  89.  
  90.  
  91. **************************************************************************
  92. *
  93. *     Message passed to InHook and OutHook
  94. *
  95. *
  96.  
  97.  STRUCTURE    XpkIOMsg,0
  98.     ULONG    xiom_Type        ; /* Read/Write/Alloc/Free/Abort    */
  99.     APTR    xiom_Ptr        ; /* The mem area to read from/write to */
  100.     LONG    xiom_Size        ; /* The size of the read/write        */
  101.     LONG    xiom_IOError        ; /* The IoErr() that occurred        */
  102.     LONG    xiom_Reserved        ; /* Reserved for future use        */
  103.     LONG    xiom_Private1        ; /* Hook specific, will be set to 0 by */
  104.     LONG    xiom_Private2        ; /* master library before first use    */
  105.     LONG    xiom_Private3        ;
  106.     LONG    xiom_Private4        ;
  107.     LABEL    xiom_SIZEOF
  108.  
  109. * The values for XpkIoMsg->Type *
  110. XIO_READ    EQU    1
  111. XIO_WRITE    EQU    2
  112. XIO_FREE    EQU    3
  113. XIO_ABORT    EQU    4
  114. XIO_GETBUF    EQU    5
  115. XIO_SEEK    EQU    6
  116. XIO_TOTSIZE    EQU    7
  117.  
  118.  
  119.  
  120.  
  121.  
  122. ******************************************************************************
  123. *
  124. *
  125. *   The progress report interface
  126. *
  127. *
  128.  STRUCTURE    XpkProgress,0
  129.     LONG    xp_Type        ; /* Type of report: start/cont/end/abort    */
  130.     APTR    xp_PackerName    ; /* Brief name of packer being used         */
  131.     APTR    xp_PackerLongName;/* Descriptive name of packer being used     */
  132.     APTR    xp_Activity    ; /* Packing/unpacking message            */
  133.     APTR    xp_FileName    ; /* Name of file being processed, if available */
  134.     LONG    xp_CCur        ; /* Amount of packed data already processed    */
  135.     LONG    xp_UCur        ; /* Amount of unpacked data already processed     */
  136.     LONG    xp_ULen        ; /* Amount of unpacked data in file        */
  137.     LONG    xp_CF        ; /* Compression factor so far            */
  138.     LONG    xp_Done        ; /* Percentage done already            */
  139.     LONG    xp_Speed    ; /* Bytes per second, from beginning of stream */
  140.     STRUCT    xp_Reserved,8*4    ; /* For future use                */
  141.     LABEL    xp_SIZEOF
  142.  
  143. XPKPROG_START    EQU    1
  144. XPKPROG_MID    EQU    2
  145. XPKPROG_END    EQU    3
  146.  
  147.  
  148.  
  149. *****************************************************************************
  150. *
  151. *
  152. *       The file info block
  153. *
  154. *
  155.  STRUCTURE    XpkFib,0
  156.     LONG    xf_Type        ; /* Unpacked, packed, archive?   */
  157.     LONG    xf_ULen        ; /* Uncompressed length          */
  158.     LONG    xf_CLen        ; /* Compressed length            */
  159.     LONG    xf_NLen        ; /* Next chunk len               */
  160.     LONG    xf_UCur        ; /* Uncompressed bytes so far    */
  161.     LONG    xf_CCur        ; /* Compressed bytes so far      */
  162.     LONG    xf_ID        ; /* 4 letter ID of packer        */
  163.     STRUCT    xf_Packer,6    ; /* 4 letter name of packer      */
  164.     WORD    xf_SubVersion    ; /* Required sublib version      */
  165.     WORD    xf_MasVersion    ; /* Required masterlib version   */
  166.     LONG    xf_Flags    ; /* Password?                    */
  167.     STRUCT    xf_Head,16    ; /* First 16 bytes of orig. file */
  168.     LONG    xf_Ratio    ; /* Compression ratio            */
  169.     STRUCT    xf_Reserved,8*4    ; /* For future use               */
  170.     LABEL    xf_SIZEOF
  171.  
  172. XPKTYPE_UNPACKED  EQU    0       ; /* Not packed                   */
  173. XPKTYPE_PACKED      EQU    1       ; /* Packed file                  */
  174. XPKTYPE_ARCHIVE   EQU    2       ; /* Archive                      */
  175.  
  176. XPKFLAGS_PASSWORD EQU    1       ; /* Password needed              */
  177. XPKFLAGS_SEEK      EQU    2       ; /* Chunks are independent       */
  178. XPKFLAGS_NONSTD   EQU    4       ; /* Nonstandard file format      */
  179.  
  180.  
  181.  
  182.  
  183. ******************************************************************************
  184. *
  185. *       The error messages
  186. *
  187. *
  188.  
  189. XPKERR_OK        EQU    0
  190. XPKERR_NOFUNC        EQU    -1    ; /* This function not implemented        */
  191. XPKERR_NOFILES        EQU    -2    ; /* No files allowed for this function        */
  192. XPKERR_IOERRIN        EQU    -3    ; /* Input error happened, look at Result2    */
  193. XPKERR_IOERROUT        EQU    -4    ; /* Output error happened, look at Result2    */
  194. XPKERR_CHECKSUM        EQU    -5    ; /* Check sum test failed            */
  195. XPKERR_VERSION        EQU    -6    ; /* Packed file's version newer than lib's    */
  196. XPKERR_NOMEM        EQU    -7    ; /* Out of memory                */
  197. XPKERR_LIBINUSE        EQU    -8    ; /* For not-reentrant libraries        */
  198. XPKERR_WRONGFORM    EQU    -9    ; /* Was not packed with this library        */
  199. XPKERR_SMALLBUF        EQU    -10    ; /* Output buffer too small            */
  200. XPKERR_LARGEBUF        EQU    -11    ; /* Input buffer too large            */
  201. XPKERR_WRONGMODE    EQU    -12    ; /* This packing mode not supported        */
  202. XPKERR_NEEDPASSWD    EQU    -13    ; /* Password needed for decoding this file    */
  203. XPKERR_CORRUPTPKD     EQU    -14    ; /* Packed file is corrupt            */
  204. XPKERR_MISSINGLIB     EQU    -15    ; /* Required library is missing        */
  205. XPKERR_BADPARAMS     EQU    -16    ; /* Caller's TagList was screwed up          */
  206. XPKERR_EXPANSION    EQU    -17    ; /* Would have caused data expansion         */
  207. XPKERR_NOMETHOD       EQU    -18    ; /* Can't find requested method              */
  208. XPKERR_ABORTED        EQU    -19    ; /* Operation aborted by user                */
  209. XPKERR_TRUNCATED    EQU    -20    ; /* Input file is truncated            */
  210. XPKERR_WRONGCPU       EQU    -21    ; /* Better CPU required for this library    */
  211. XPKERR_PACKED         EQU    -22    ; /* Data are already XPacked            */
  212. XPKERR_NOTPACKED      EQU    -23    ; /* Data not packed                */
  213. XPKERR_FILEEXISTS     EQU    -24    ; /* File already exists            */
  214. XPKERR_OLDMASTLIB     EQU    -25    ; /* Master library too old            */
  215. XPKERR_OLDSUBLIB      EQU    -26    ; /* Sub library too old            */
  216. XPKERR_NOCRYPT        EQU    -27    ; /* Cannot encrypt                */
  217. XPKERR_NOINFO         EQU    -28    ; /* Can't get info on that packer        */
  218. XPKERR_LOSSY        EQU    -29    ; /* This compression method is lossy        */
  219. XPKERR_NOHARDWARE    EQU    -30    ; /* Compression hardware required        */
  220. XPKERR_BADHARDWARE    EQU    -31    ; /* Compression hardware failed        */
  221. XPKERR_WRONGPW        EQU    -32    ; /* Password was wrong                */
  222.  
  223.  
  224. XPKERRMSGSIZE        EQU    80    ; /* Maximum size of an error message        */
  225.  
  226.  
  227.  
  228.  
  229.  
  230. *****************************************************************************
  231. *
  232. *
  233. *     The XpkQuery() call
  234. *
  235. *
  236.  
  237.  STRUCTURE XpkPackerInfo,0
  238.     STRUCT  xpi_Name,24         ; /* Brief name of the packer          */
  239.     STRUCT  xpi_LongName,32     ; /* Full name of the packer           */
  240.     STRUCT  xpi_Description,80  ; /* One line description of packer    */
  241.     LONG    xpi_Flags           ; /* Defined below                     */
  242.     LONG    xpi_MaxChunk        ; /* Max input chunk size for packing  */
  243.     LONG    xpi_DefChunk        ; /* Default packing chunk size        */
  244.     UWORD   xpi_DefMode         ; /* Default mode on 0..100 scale      */
  245.     LABEL   xpi_SIZEOF
  246.  
  247. XPKIF_PK_CHUNK   EQU    $00000001   ; /* Library supplies chunk packing       */
  248. XPKIF_PK_STREAM  EQU    $00000002   ; /* Library supplies stream packing      */
  249. XPKIF_PK_ARCHIVE EQU    $00000004   ; /* Library supplies archive packing     */
  250. XPKIF_UP_CHUNK   EQU    $00000008   ; /* Library supplies chunk unpacking     */
  251. XPKIF_UP_STREAM  EQU    $00000010   ; /* Library supplies stream unpacking    */
  252. XPKIF_UP_ARCHIVE EQU    $00000020   ; /* Library supplies archive unpacking   */
  253. XPKIF_HOOKIO     EQU    $00000080   ; /* Uses full Hook I/O                   */
  254. XPKIF_CHECKING   EQU    $00000400   ; /* Does its own data checking           */
  255. XPKIF_PREREADHDR EQU    $00000800   ; /* Unpacker pre-reads the next chunkhdr */
  256. XPKIF_ENCRYPTION EQU    $00002000   ; /* Sub library supports encryption      */
  257. XPKIF_NEEDPASSWD EQU    $00004000   ; /* Sub library requires encryption      */
  258. XPKIF_MODES      EQU    $00008000   ; /* Sub library has different modes      */
  259. XPKIF_LOSSY      EQU    $00010000   ; /* Sub library does lossy compression   */
  260.  
  261.  STRUCTURE XpkMode,0
  262.     APTR    xm_Next          ; /* Chain to next descriptor for ModeDesc list*/
  263.     ULONG   xm_Upto          ; /* Maximum efficiency handled by this mode   */
  264.     ULONG   xm_Flags         ; /* Defined below                             */
  265.     ULONG   xm_PackMemory    ; /* Extra memory required during packing      */
  266.     ULONG   xm_UnpackMemory  ; /* Extra memory during unpacking             */
  267.     ULONG   xm_PackSpeed     ; /* Approx packing speed in K per second      */
  268.     ULONG   xm_UnpackSpeed   ; /* Approx unpacking speed in K per second    */
  269.     UWORD   xm_Ratio         ; /* CF in 0.1% for AmigaVision executable     */
  270.     UWORD   xm_ChunkSize     ; /* Desired chunk size in K (!!) for this mode*/
  271.     STRUCT  xm_Description,10; /* 8 character mode description              */
  272.     LABEL   xm_SIZEOF
  273.  
  274. XPKMF_A3000SPEED EQU $00000001    ; /* Timings on A3000/25               */
  275. XPKMF_PK_NOCPU   EQU $00000002    ; /* Packing not heavily CPU dependent */
  276. XPKMF_UP_NOCPU   EQU $00000004    ; /* Unpacking... (i.e. hardware modes)*/
  277.  
  278.  
  279. MAXPACKERS    EQU    100
  280.  
  281.  STRUCTURE XpkPackerList,0
  282.     ULONG    xpl_NumPackers;
  283.     STRUCT    xpl_Packer,MAXPACKERS*6;
  284.     LABEL    xpl_SIZEOF
  285.  
  286.  
  287. *****************************************************************************
  288. *
  289. *
  290. *     The XpkOpen() type calls
  291. *
  292. */
  293.  
  294. XPKLEN_ONECHUNK EQU $7fffffff
  295.  
  296.  
  297.  
  298.  
  299.     LIBINIT
  300.     LIBDEF    _LVOXpkPackerInfo    ; do not use
  301.     LIBDEF    _LVOXpkExamine
  302.     LIBDEF    _LVOXpkPack
  303.     LIBDEF    _LVOXpkUnpack
  304.     LIBDEF    _LVOXpkOpen
  305.     LIBDEF    _LVOXpkRead
  306.     LIBDEF    _LVOXpkWrite
  307.     LIBDEF    _LVOXpkSeek
  308.     LIBDEF    _LVOXpkClose
  309.     LIBDEF    _LVOXpkQuery
  310.  
  311.     ENDC
  312.